<%--
  ~ Copyright (c) 2016. 恒昌互联网运营中心.
  --%>

<!DOCTYPE html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<html lang="zh-CN" style="height: 100%">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <meta name="description" cotent="">
    <meta name="author" content="">
    <title>鹰眼监控平台-${title}</title>
    <%@ include file="/WEB-INF/views/common/include.jsp" %>
    <style type="text/css">
        .runtimeBar{
            display:inline-block;
            height:8px;
        }
    </style>

    <script type="text/javascript">
        var timer;
        $(document).ready(function () {
            //getRedisEnvList();
            //timer=setInterval("getData()", 5000);
            //$("#trace_tree_table").treetable({expandable: true});
        });


        /**type:1:success,2:info,3:warning,4:danger*/
        function alertInfo(type, msg) {
            if (type == "1") {
                $.scojs_message(msg, $.scojs_message.TYPE_OK);
            } else if (type == "4") {
                $.scojs_message(msg, $.scojs_message.TYPE_ERROR);
            }
        }
        function editPlatformList() {
            $("#settingJson").val("");
            $.ajax({
                url : "loadPlatformList",
                data : {
                },
                success : function(result) {
                    if (result.code == "1") {
                        $("#platformListJson").val(result.data);
                        $("#platformListModal").modal("show");
                    } else {
                        alertInfo("4", result.message);
                    }
                },
                async : false,
                dataType : "json"
            });
        }

        function savePlatformList(){
            $.ajax({
                url : "savePlatformList",
                type: "post",
                data : {
                    "platformListJson":$("#platformListJson").val()
                },
                success : function(result) {
                    if (result.code === "1") {
                        alert("保存成功");
                    } else {
                        alertInfo("4", result.message);
                    }
                },
                async : false,
                dataType : "json"
            });
        }

        function editUserList() {
            $("#settingJson").val("");
            $.ajax({
                url : "loadUserList",
                data : {
                },
                success : function(result) {
                    if (result.code == "1") {
                        $("#userListJson").val(result.data);
                        $("#userListModal").modal("show");
                    } else {
                        alertInfo("4", result.message);
                    }
                },
                async : false,
                dataType : "json"
            });
        }

        function saveUserList(){
            $.ajax({
                url : "saveUserList",
                type: "post",
                data : {
                    "userListJson":$("#userListJson").val()
                },
                success : function(result) {
                    if (result.code === "1") {
                        alert("保存成功");
                    } else {
                        alertInfo("4", result.message);
                    }
                },
                async : false,
                dataType : "json"
            });
        }

        function editSetting() {
            $("#settingJson").val("");
            $.ajax({
                url : "loadSetting",
                data : {
                },
                success : function(result) {
                    if (result.code == "1") {
                        $("#settingJson").val(result.data);
                        $("#settingModal").modal("show");
                    } else {
                        alertInfo("4", result.message);
                    }
                },
                async : false,
                dataType : "json"
            });
        }

        function saveSetting(){
            $.ajax({
                url : "saveSetting",
                type: "post",
                data : {
                    "settingJson":$("#settingJson").val()
                },
                success : function(result) {
                    if (result.code === "1") {
                        alert("保存成功");
                    } else {
                        alertInfo("4", result.message);
                    }
                },
                async : false,
                dataType : "json"
            });
        }


    </script>
</head>
<body style="height: 100%">
<%@ include file="/WEB-INF/views/common/top.jsp" %>
<div class="container-fluid" style="height: 100%">
    <%@ include file="/WEB-INF/views/common/left.jsp" %>

    <div class="col-sm-10 col-sm-offset-2 col-md-11 col-md-offset-1" style="height: 100%">
        <h2 class="page-header">${title}</h2>
        <form class="form-inline " action="nodeStatus" method="post">
            <div class="form-group">
                <button type='button' class='btn btn-primary' onclick='editSetting()'>编辑平台枚举</button>
                <button type='button' class='btn btn-info' onclick='editPlatformList();'>编辑平台列表</button>
                <button type='button' class='btn btn-success' onclick='editUserList();'>编辑用户授权</button>
            </div>

        </form>

        <div id="echarts_div" style="width: 100%;height:90%;"></div>
        <!-- 平台列表信息框（Modal） -->
        <div class="modal fade" id="platformListModal" tabindex="-1" role="dialog" aria-labelledby="platformListLabel" aria-hidden="true" >
            <div class="modal-dialog modal-lg">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <h4 class="modal-title" id="platformListLabel">平台列表</h4>
                    </div>
                    <div class="modal-body">
                        <div id="parametersDiv">
                            JSON:<p>
                            <textarea id="platformListJson" class="form-control" rows="15"></textarea>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-primary" onclick="savePlatformList()">保存</button>
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    </div>
                </div>
                <!-- /.modal-content -->
            </div>
            <!-- /.modal -->
        </div>

        <!-- 用户列表信息框（Modal） -->
        <div class="modal fade" id="userListModal" tabindex="-1" role="dialog" aria-labelledby="userListLabel" aria-hidden="true" >
            <div class="modal-dialog modal-lg">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <h4 class="modal-title" id="userListLabel">用户列表</h4>
                    </div>
                    <div class="modal-body">
                        <div>
                            JSON:<p>
                            <textarea id="userListJson" class="form-control" rows="15"></textarea>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-primary" onclick="saveUserList()">保存</button>
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    </div>
                </div>
                <!-- /.modal-content -->
            </div>
            <!-- /.modal -->
        </div>
        <!-- 平台配置信息框（Modal） -->
        <div class="modal fade" id="settingModal" tabindex="-1" role="dialog" aria-labelledby="settingLabel" aria-hidden="true" >
            <div class="modal-dialog modal-lg">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <h4 class="modal-title" id="settingLabel">平台配置</h4>
                    </div>
                    <div class="modal-body">
                        <div id="parametersDiv">
                            JSON:<p>
                            <textarea id="settingJson" class="form-control" rows="15"></textarea>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-primary" onclick="saveSetting()">保存</button>
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    </div>
                </div>
                <!-- /.modal-content -->
            </div>
            <!-- /.modal -->
        </div>
    </div>
</body>
</html>
